//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
        //1.二分查找——BM1二分查找|
        public int search (int[] nums, int target) {
            int len = nums.length;
            if(len == 0) {
                return -1;
            }
            int left = 0;
            int right = len - 1;
            int mid = 0;
            while (left <= right) {
                mid = (left + right) / 2;
                if (target > nums[mid]) {
                    left = mid + 1;

                } else if(target < nums[mid]) {
                    right = mid - 1;

                } else {
                    return mid;
                }
            }
            return -1;
        }
        //2.BM21旋转数组的最小数字
        public int minNumberInRotateArray (int[] nums) {
            int len = nums.length;
            int left = 0;
            int right = len - 1;
            int tmp = 0;
            while(left < right) {
                if(nums[left] >= nums[right]) {
                    tmp = nums[right];
                    left++;
                } else{
                    tmp = nums[left];
                    right--;
                }
            }
            return tmp;
        }
    }
}